package com.heima.wemedia.controller.v1;

import com.heima.model.comment.dtos.CommentPageDTo;
import com.heima.model.comment.dtos.CommentRepayDto;
import com.heima.model.comment.dtos.OpenOrCloseCommentDTO;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.CommentManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author itlxc
 * @since 2024-07-31
 */
@RestController
@RequestMapping("/wemedia/api/v1/comment/manage")
@Slf4j
@RequiredArgsConstructor
public class CommentManageController {

    private final CommentManageService commentManageService;

    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult deleteComment(@PathVariable String commentId) {
        log.info("删除评论:{}", commentId);
        return commentManageService.deleteComment(commentId);
    }

    @DeleteMapping("del_comment_repay/{commentRepayId}")
    public ResponseResult deleteCommentRepay(@PathVariable String commentRepayId) {
        log.info("删除评论回复:{}", commentRepayId);
        return commentManageService.deleteCommentRepay(commentRepayId);
    }

    @PostMapping("/comment_repay")
    public ResponseResult saveCommentRepay(@RequestBody CommentRepayDto dto) {
        log.info("评论回复:{}", dto);
        return commentManageService.saveCommentRepay(dto);
    }

    @PostMapping("/update_comment_status")
    public ResponseResult openOrCloseComment(@RequestBody OpenOrCloseCommentDTO dto) {
        log.info("打开或关闭评论:{}", dto);
        return commentManageService.openOrCloseComment(dto);
    }

}
